package com.freesky.biz.rights.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.freesky.biz.rights.domain.RightsQuesEntity;
import com.freesky.biz.rights.domain.RightsQuesOptionEntity;
import com.freesky.biz.rights.mapper.RightsQuesMapper;
import com.freesky.biz.rights.mapper.RightsQuesOptionMapper;
import com.freesky.biz.rights.service.IRightsQuesOptionService;
import com.freesky.biz.rights.service.IRightsQuesService;
import com.freesky.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * 题目管理Service实现
 */
@Service
public class RightsQuesOptionServiceImpl extends ServiceImpl<RightsQuesOptionMapper, RightsQuesOptionEntity> implements IRightsQuesOptionService {

    @Autowired
    private RightsQuesOptionMapper optionMapper;

    @Override
    public boolean insertQuesOption(RightsQuesOptionEntity quesOption) {
        return optionMapper.insert(quesOption) > 0 ;
    }

    @Override
    public boolean updateQuesOption(RightsQuesOptionEntity quesOption) {
        return optionMapper.updateById(quesOption) > 0;
    }

    @Override
    public boolean deleteQuesOption(String[] quesOptionIds) {
        LambdaUpdateWrapper<RightsQuesOptionEntity> wrapper = new LambdaUpdateWrapper<>();
        wrapper.in(RightsQuesOptionEntity::getOptionId, quesOptionIds);
        wrapper.eq(RightsQuesOptionEntity::getDelFlag, "0");
        wrapper.set(RightsQuesOptionEntity::getDelFlag,"1");
        return optionMapper.update(wrapper)>0;
    }
}